package lihao3;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Test1 {
    public static void main(String[] args) throws Exception {
        File file1 = new File("C:/a.txt");
        File file2 = new File("D:/test/a.txt");
        System.out.println(file2.exists());
        if (!file2.exists()) {
            file2.mkdir();
            file2.createNewFile();
        }
        FileInputStream in = new FileInputStream(file1);
        FileOutputStream out = new FileOutputStream(file2);
        byte[] b = new byte[1024];
        int len = 0;
        while((len = in.read(b))!=-1){
            out.write(b,0,len);
            out.flush();
        }
        out.close();
        in.close();

    }
}
